/*
 * Copyright 2010 Cedric Priscal
 *
 * This file is part of stupid-avr-robot.
 *
 * stupid-avr-robot is free software: you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * stupid-avr-robot is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with stupid-avr-robot.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef BLINK_H_
#define BLINK_H_

#include "Timer/Timer.h"
#include "PropertyBoolean.h"
#include "PropertyBlinkEnabled.h"

/**
 * @brief Blinking LED.
 *
 * Use this class to make the Arduino onboard LED
 * (GPIO B5 of ATMEGA328) blink at a 2 seconds period.
 */
class Blink: private TimerListener, public Property, public PropertyListener {

private:
    unsigned short mTimeMs;
    char mRequestId;
    void onTimer(char what, unsigned short when);

public:
    /**
     * @brief Constructor.
     *
     * Blinking is not activated in this constructor.
     * @see setEnabled()
     */
    Blink();

    /**
     * @brief Enable or disable the blinking.
     */
    PropertyBlinkEnabled mEnabled;

    PROPERTY_TYPE getType() { return PROPERTY_TYPE_VOID; }
	const char* getName() { return "Blink"; }
	const char* getDescription() { return "LED blinking"; }
	Property* getChild(unsigned char index);

    void onPropertyChanged(class Property* prop);
};

#endif /* BLINK_H_ */
